package com.kitty.game.equip.service;

import com.kitty.common.utils.SpringUtils;
import com.kitty.game.config.NPC;
import com.kitty.game.npc.NpcDataPool;
import com.kitty.game.npc.model.NpcButton;
import com.kitty.game.role.model.Role;
import org.springframework.stereotype.Service;

@Service
public class ShuadaoService {
    public void init() {
       //shuadao_open_sanbei("开启三倍");
       //shuadao_close_sanbei("关闭你三倍");
       //shuadao_open_wubei("开启三倍");
       //shuadao_close_wubei("关闭五倍");
        NpcDataPool.npcButtonHandlers.put(NpcButton.shuadao_open_sanbei.getKey(), (npcButtonParam -> SpringUtils.getBean(ShuadaoService.class).shuadao(npcButtonParam.getRole(), npcButtonParam.getMsg())));
        NpcDataPool.npcButtonHandlers.put(NpcButton.shuadao_close_sanbei.getKey(), (npcButtonParam -> SpringUtils.getBean(ShuadaoService.class).shuadao(npcButtonParam.getRole(), npcButtonParam.getMsg())));
        NpcDataPool.npcButtonHandlers.put(NpcButton.shuadao_open_wubei.getKey(), (npcButtonParam -> SpringUtils.getBean(ShuadaoService.class).shuadao(npcButtonParam.getRole(), npcButtonParam.getMsg())));
        NpcDataPool.npcButtonHandlers.put(NpcButton.shuadao_close_wubei.getKey(), (npcButtonParam -> SpringUtils.getBean(ShuadaoService.class).shuadao(npcButtonParam.getRole(), npcButtonParam.getMsg())));
    }

    private void shuadao(Role role, String msg) {
        if (msg.equals(NpcButton.shuadao_open_sanbei.getKey())){
            role.getPropsStatus().setv("san_bei",1);
            role.getPropsStatus().setv("wu_bei",0);
        }else if (msg.equals(NpcButton.shuadao_close_sanbei.getKey())){
            role.getPropsStatus().setv("san_bei",0);
        }else if (msg.equals(NpcButton.shuadao_open_wubei.getKey())){
            role.getPropsStatus().setv("wu_bei",1);
            role.getPropsStatus().setv("san_bei",0);
        }else if (msg.equals(NpcButton.shuadao_close_wubei.getKey())){
            role.getPropsStatus().setv("wu_bei",0);
        }
        role.save();
    }

    public String point(NPC npc,Role role){
        String content = npc.getContent();
//        if (true){
//            return content;
//        }
        StringBuilder change = new StringBuilder();
//        if (role.getPropsStatus().getInt("san_bei",0) ==0){
//            change.append("["+NpcButton.shuadao_open_sanbei.getKey()+"]");
//        }else {
//            change.append("["+NpcButton.shuadao_close_sanbei.getKey()+"]");
//        }
//        if (role.getPropsStatus().getInt("wu_bei",0) ==0){
//            change.append("["+NpcButton.shuadao_open_wubei.getKey()+"]");
//        }else {
//            change.append("["+NpcButton.shuadao_close_wubei.getKey()+"]");
//        }
        if (npc.getName().equals("通灵道人")){
            return "如今妖魔祸乱，而贫道无法分身前往，这可如何是好？[【一阶】降妖/dispatch_shuadao]"+change.toString()+"[离开/离开]";
        }else if (npc.getName().equals("陆压真人")){
            //贫道云游四方，近日夜观星象得知中洲大陆有妖邪作乱。贫道苦于繁事缠身，故在此等候能人异士代我前去伏魔除秽。不知仙友可有此意？[【一阶】伏魔/dispatch_shuadao][【二阶】伏魔/dispatch_shuadao2][便捷组队/quick_match][我才懒得管/离开]
            return "贫道云游四方，近日夜观星象得知中洲大陆有妖邪作乱。贫道苦于繁事缠身，故在此等候能人异士代我前去伏魔除秽。不知仙友可有此意？[【一阶】伏魔/dispatch_shuadao][【二阶】伏魔/dispatch_shuadao2]"+change.toString()+"[我才懒得管/离开]";
        }else if (npc.getName().equals("清微真人")){
            //传说当年周公以八卦之理推演八卦图，今由#Y青龙#n、#Y白虎#n、#Y朱雀#n、#Y玄武#n四圣看守。[【一阶】飞仙渡邪/dispatch_shuadao][【二阶】飞仙渡邪/dispatch_shuadao2][便捷组队/飞仙渡邪_quick_match_team][离开/离开]
            return "传说当年周公以八卦之理推演八卦图，今由#Y青龙#n、#Y白虎#n、#Y朱雀#n、#Y玄武#n四圣看守。[【一阶】飞仙渡邪/dispatch_shuadao][【二阶】飞仙渡邪/dispatch_shuadao2]"+change.toString()+"[离开/离开]";
        }
        return "如今妖魔祸乱，而贫道无法分身前往，这可如何是好？[【一阶】降妖/dispatch_shuadao][离开/离开]";
    }
}
